package main

import (
	"encoding/json"
	"fmt"
	"google.golang.org/protobuf/proto"
	"strconv"
	"wzgames/internal/codec/sfs"
	"wzgames/internal/constant"
	"wzgames/internal/model"
	"wzgames/internal/model/agentp"
	"wzgames/internal/model/aviatorp"
	"wzgames/internal/model/gamep"
	"wzgames/internal/model/gkindp"
	"wzgames/internal/model/mcomm"
	"wzgames/internal/model/roulettep"
	"wzgames/pkg/remote/etcd"
	"wzgames/pkg/server/http"
	"wzgames/pkg/server/rpcx"
	"wzgames/pkg/server/ws"
	"wzgames/pkg/utils/byteutil"
	"wzgames/pkg/utils/dateutil"
	"wzgames/pkg/utils/stringutil"
)

var etcdClient *etcd.EtcdClient
var err error
var env constant.EnvType

// 本地服系统初始化
func main() {
	etcdClient = etcd.NewEtcdClient(&etcd.EtcdConfig{
		Addrs: []string{"localhost:2379"},
	})
	err = etcdClient.CheckClientKV()
	if err != nil {
		panic(err)
	}
	defer etcdClient.Close()

	env = constant.EnvDev
	constant.InitEnv(env)

	//addSysConfig()
	//addSysCurrency()
	//addSysGames()
	//addMaintain()

	//addAgent()
	//addAgentGuest()

	//addCatNode("1", 3, 4, "localhost:20881", "0.0.0.0:20881")
	//addUcNode("1", 4, 5, "localhost:20882", "0.0.0.0:20882")
	//addBetTowerNode("1", 8, 7, "localhost:20884", "0.0.0.0:20884")
	//addApiNode("1", 1, 1, "0.0.0.0", "8899")
	//addG8Node("1", 2, 2, "ws://localhost:9110/BlueBox/websocket")
	//addAviatorNode("1", 5, 3, "ws://localhost:9111/BlueBox/websocket")
	//addAvTowerNode("1", 6)
	//addRouBigNode("1", 10, 6, "ws://localhost:9112/BlueBox/websocket")
	//addRouTowerNode("1", 11)
	//addAdminNode("1", 9, 8, 9, "0.0.0.0", "8855", "ws://localhost:9222/BlueBox/websocket")

	//AviatorGameInstConf()
	//DiceGameInstConf()
	//MinesGameInstConf()
	//HotlineGameInstConf()
	//KenoGameInstConf()
	//PlinkoGameInstConf()
	//RouletteGameInstConf()
	//HiloGameInstConf()
	//GoalGameInstConf()

	//RouletteBigGameInstConf()

	fmt.Println("init ok")
}

func addCatNode(idx string, nodeId, servId int64, servAddr, bindAddr string) {
	nd := &model.Node{
		NodeId:   nodeId,
		NodeKey:  "dev-cat-" + idx,
		Name:     "dev-cat-" + idx,
		Timezone: "",
		Env:      env,
		Group:    constant.CatNd,
		Status:   constant.Up,
		RpcConf: &rpcx.RPCxConfig{
			NodeId:         nodeId,
			ServID:         servId,
			ServName:       "cat-service",
			BasePath:       constant.RPCxBasePath,
			ServAddr:       servAddr,
			BindAddr:       bindAddr,
			UpdateInterval: 10,
			MaxQPS:         1000,
			Weight:         10,
			Meta:           "",
			Username:       "",
			Password:       "",
		},
	}
	b, err1 := json.Marshal(nd)
	if err1 != nil {
		panic(err1)
	}
	_, err = etcdClient.Store(constant.CcNodesRoot+"/"+nd.NodeKey, byteutil.SliceByteToString(b))
	if err != nil {
		panic(err)
	}
}

func addUcNode(idx string, nodeId, servId int64, servAddr, bindAddr string) {
	nd := &model.Node{
		NodeId:   nodeId,
		NodeKey:  "dev-uc-" + idx,
		Name:     "dev-uc-" + idx,
		Timezone: "",
		Env:      env,
		Group:    constant.UcNd,
		Status:   constant.Up,
		RpcConf: &rpcx.RPCxConfig{
			NodeId:         nodeId,
			ServID:         servId,
			ServName:       "uc-service",
			BasePath:       constant.RPCxBasePath,
			ServAddr:       servAddr,
			BindAddr:       bindAddr,
			UpdateInterval: 10,
			MaxQPS:         1000,
			Weight:         10,
			Meta:           "",
			Username:       "",
			Password:       "",
		},
	}
	b, err1 := json.Marshal(nd)
	if err1 != nil {
		panic(err1)
	}
	_, err = etcdClient.Store(constant.CcNodesRoot+"/"+nd.NodeKey, byteutil.SliceByteToString(b))
	if err != nil {
		panic(err)
	}
}

func addBetTowerNode(idx string, nodeId, servId int64, servAddr, bindAddr string) {
	nd := &model.Node{
		NodeId:   nodeId,
		NodeKey:  "dev-betower-" + idx,
		Name:     "dev-betower-" + idx,
		Timezone: "",
		Env:      env,
		Group:    constant.BetTowerNd,
		Status:   constant.Up,
		RpcConf: &rpcx.RPCxConfig{
			NodeId:         nodeId,
			ServID:         servId,
			ServName:       "betower-service",
			BasePath:       constant.RPCxBasePath,
			ServAddr:       servAddr,
			BindAddr:       bindAddr,
			UpdateInterval: 10,
			MaxQPS:         1000,
			Weight:         10,
			Meta:           "",
			Username:       "",
			Password:       "",
		},
	}
	b, err1 := json.Marshal(nd)
	if err1 != nil {
		panic(err1)
	}
	_, err = etcdClient.Store(constant.CcNodesRoot+"/"+nd.NodeKey, byteutil.SliceByteToString(b))
	if err != nil {
		panic(err)
	}
}

func addApiNode(idx string, nodeId, servId int64, host, port string) {
	nd := &model.Node{
		NodeId:   nodeId,
		NodeKey:  "dev-api-" + idx,
		Name:     "dev-api-" + idx,
		Timezone: "",
		Env:      env,
		Group:    constant.ApiNd,
		Status:   constant.Up,
		HttpConf: &http.HttpConfig{
			ServID: servId,
			Ip:     host,
			Port:   port,
			Mod:    "debug",
		},
	}
	b, err1 := json.Marshal(nd)
	if err1 != nil {
		panic(err1)
	}
	_, err2 := etcdClient.Store(constant.CcNodesRoot+"/"+nd.NodeKey, byteutil.SliceByteToString(b))
	if err2 != nil {
		panic(err2)
	}
}

func addG8Node(idx string, nodeId, wsServId int64, wsAddr string) {
	nd := &model.Node{
		NodeId:   nodeId,
		NodeKey:  "dev-g8-" + idx,
		Name:     "dev-g8-" + idx,
		Timezone: "",
		Env:      env,
		Group:    constant.G8Nd,
		Status:   constant.Up,
		WsConf: &ws.WsConfig{
			ServID: wsServId,
			Addr:   wsAddr,
		},
	}
	b, err1 := json.Marshal(nd)
	if err1 != nil {
		panic(err1)
	}
	_, err = etcdClient.Store(constant.CcNodesRoot+"/"+nd.NodeKey, byteutil.SliceByteToString(b))
	if err != nil {
		panic(err)
	}
}

func addAviatorNode(idx string, nodeId, wsServId int64, wsAddr string) {
	nd := &model.Node{
		NodeId:   nodeId,
		NodeKey:  "dev-aviator-" + idx,
		Name:     "dev-aviator-" + idx,
		Timezone: "",
		Env:      env,
		Group:    constant.AviatorNd,
		Status:   constant.Up,
		WsConf: &ws.WsConfig{
			ServID: wsServId,
			Addr:   wsAddr,
		},
	}
	b, err1 := json.Marshal(nd)
	if err1 != nil {
		panic(err1)
	}
	_, err = etcdClient.Store(constant.CcNodesRoot+"/"+nd.NodeKey, byteutil.SliceByteToString(b))
	if err != nil {
		panic(err)
	}
}

func addAvTowerNode(idx string, nodeId int64) {
	nd := &model.Node{
		NodeId:   nodeId,
		NodeKey:  "dev-avtower-" + idx,
		Name:     "dev-avtower-" + idx,
		Timezone: "",
		Env:      env,
		Group:    constant.AvTowerNd,
		Status:   constant.Up,
	}
	b, err1 := json.Marshal(nd)
	if err1 != nil {
		panic(err1)
	}
	_, err = etcdClient.Store(constant.CcNodesRoot+"/"+nd.NodeKey, byteutil.SliceByteToString(b))
	if err != nil {
		panic(err)
	}
}

func addAdminNode(idx string, nodeId, httpServId, wsServId int64, host, port, wsAddr string) {
	nd := &model.Node{
		NodeId:   nodeId,
		NodeKey:  "dev-admin-" + idx,
		Name:     "dev-admin-" + idx,
		Timezone: "",
		Env:      env,
		Group:    constant.AdminNd,
		Status:   constant.Up,
		HttpConf: &http.HttpConfig{
			ServID: httpServId,
			Ip:     host,
			Port:   port,
			Mod:    "debug",
		},
		WsConf: &ws.WsConfig{
			ServID: wsServId,
			Addr:   wsAddr,
		},
	}
	b, err1 := json.Marshal(nd)
	if err1 != nil {
		panic(err1)
	}
	_, err = etcdClient.Store(constant.CcNodesRoot+"/"+nd.NodeKey, byteutil.SliceByteToString(b))
	if err != nil {
		panic(err)
	}
}

func addRouBigNode(idx string, nodeId, wsServId int64, wsAddr string) {
	nd := &model.Node{
		NodeId:   nodeId,
		NodeKey:  "dev-roubig-" + idx,
		Name:     "dev-roubig-" + idx,
		Timezone: "",
		Env:      env,
		Group:    constant.RouBigNd,
		Status:   constant.Up,
		WsConf: &ws.WsConfig{
			ServID: wsServId,
			Addr:   wsAddr,
		},
	}
	b, err1 := json.Marshal(nd)
	if err1 != nil {
		panic(err1)
	}
	_, err = etcdClient.Store(constant.CcNodesRoot+"/"+nd.NodeKey, byteutil.SliceByteToString(b))
	if err != nil {
		panic(err)
	}
}

func addRouTowerNode(idx string, nodeId int64) {
	nd := &model.Node{
		NodeId:   nodeId,
		NodeKey:  "dev-routower-" + idx,
		Name:     "dev-routower-" + idx,
		Timezone: "",
		Env:      env,
		Group:    constant.RouTowerNd,
		Status:   constant.Up,
	}
	b, err1 := json.Marshal(nd)
	if err1 != nil {
		panic(err1)
	}
	_, err = etcdClient.Store(constant.CcNodesRoot+"/"+nd.NodeKey, byteutil.SliceByteToString(b))
	if err != nil {
		panic(err)
	}
}

func addSysConfig() {
	c := &model.GSys{
		RedisC: &model.RedisConfig{
			ServerConfigs: []*model.PoolConfig{
				{
					Name:            "redis-sys",
					Server:          "127.0.0.1:6379",
					DB:              0,
					Username:        "",
					Password:        "",
					MaxRetries:      1,
					DialTimeout:     5,
					ReadTimeout:     5,
					WriteTimeout:    5,
					MinIdleConns:    10,
					MaxIdleConns:    100,
					ConnMaxIdleTime: 10,
				},
			},
		},
		WdbC: &model.DBConfig{ProxyConfigs: []*model.DBC{
			{
				Name:            "wz-admin",
				DriverName:      "mysql",
				User:            "root",
				Password:        "admin888",
				Host:            "localhost",
				Port:            "3306",
				SchemaName:      "wz_admin",
				MaxOpenConns:    10,
				MaxIdleConns:    5,
				ConnMaxLifetime: 0,
				Dateline:        dateutil.UnixSecs(),
			},
			{
				Name:            "wz-aviator",
				DriverName:      "mysql",
				User:            "root",
				Password:        "admin888",
				Host:            "localhost",
				Port:            "3306",
				SchemaName:      "wz_aviator",
				MaxOpenConns:    10,
				MaxIdleConns:    5,
				ConnMaxLifetime: 0,
				Dateline:        dateutil.UnixSecs(),
			},
			{
				Name:            "wz-id",
				DriverName:      "mysql",
				User:            "root",
				Password:        "admin888",
				Host:            "localhost",
				Port:            "3306",
				SchemaName:      "wz_idgen",
				MaxOpenConns:    10,
				MaxIdleConns:    5,
				ConnMaxLifetime: 0,
				Dateline:        dateutil.UnixSecs(),
			},
			{
				Name:            "wz-user",
				DriverName:      "mysql",
				User:            "root",
				Password:        "admin888",
				Host:            "localhost",
				Port:            "3306",
				SchemaName:      "wz_user_biz",
				MaxOpenConns:    10,
				MaxIdleConns:    5,
				ConnMaxLifetime: 0,
				Dateline:        dateutil.UnixSecs(),
			},
			{
				Name:            "wz-wallet",
				DriverName:      "mysql",
				User:            "root",
				Password:        "admin888",
				Host:            "localhost",
				Port:            "3306",
				SchemaName:      "wz_wallet",
				MaxOpenConns:    10,
				MaxIdleConns:    5,
				ConnMaxLifetime: 0,
				Dateline:        dateutil.UnixSecs(),
			},
			{
				Name:            "wz-b-history",
				DriverName:      "mysql",
				User:            "root",
				Password:        "admin888",
				Host:            "localhost",
				Port:            "3306",
				SchemaName:      "wz_b_history",
				MaxOpenConns:    10,
				MaxIdleConns:    5,
				ConnMaxLifetime: 0,
				Dateline:        dateutil.UnixSecs(),
			},
			{
				Name:            "wz-roulette",
				DriverName:      "mysql",
				User:            "root",
				Password:        "admin888",
				Host:            "localhost",
				Port:            "3306",
				SchemaName:      "wz_roulette",
				MaxOpenConns:    10,
				MaxIdleConns:    5,
				ConnMaxLifetime: 0,
				Dateline:        dateutil.UnixSecs(),
			},
		}},
		MqC: &model.MqConfig{
			BrokerConfigs: []*model.MqC{
				{
					Name:        "rabbitmq",
					User:        "admin",
					Password:    "admin",
					Host:        "localhost",
					Port:        "5672",
					VirtualHost: "/",
				},
			},
		},
		NatsC: &model.NatsConfig{Server: "nats://localhost:4222"},
	}
	b, err1 := json.Marshal(c)
	if err1 != nil {
		panic(err1)
	}
	_, err = etcdClient.Store(constant.CcCommRoot+"/sys", byteutil.SliceByteToString(b))
	if err != nil {
		panic(err)
	}
}

func addSysCurrency() {
	currs := &mcomm.SysCurrencies{
		DataList: map[string]*mcomm.SysCurrency{
			"USD": {
				CurrID:    1,
				Curr:      "USD",
				CurrType:  mcomm.CurrencyType_FiatCurr,
				Status:    mcomm.Status_Up,
				Precision: 2,
			},
			"EUR": {
				CurrID:    2,
				Curr:      "EUR",
				CurrType:  mcomm.CurrencyType_FiatCurr,
				Status:    mcomm.Status_Up,
				Precision: 2,
			},
			"GOLD": {
				CurrID:    3,
				Curr:      "GOLD",
				CurrType:  mcomm.CurrencyType_TokenCurr,
				Status:    mcomm.Status_Up,
				Precision: 2,
			},
		},
		CurrIdMap: map[int32]string{
			1: "USD",
			2: "EUR",
			3: "GOLD",
		},
	}
	b, err1 := proto.Marshal(currs)
	if err1 != nil {
		panic(err1)
	}
	_, err = etcdClient.Store(constant.CcCommRoot+"/currency", byteutil.SliceByteToString(b))
	if err != nil {
		panic(err)
	}
}

func addSysGames() {
	var games []*gamep.WzGame
	langs := map[string]string{
		"en": "en",
		"zh": "zh",
	}
	t := dateutil.UnixSecs()
	games = append(games, &gamep.WzGame{
		GameID:   100,
		GameName: "Aviator",
		Tag:      "aviator",
		Status:   mcomm.Status_Up,
		Langs:    langs,
		Grp:      1,
		Updated:  t,
	}, &gamep.WzGame{
		GameID:   101,
		GameName: "Mines",
		Tag:      "mines",
		Status:   mcomm.Status_Up,
		Langs:    langs,
		Grp:      2,
		Updated:  t,
	}, &gamep.WzGame{
		GameID:   102,
		GameName: "Dice",
		Tag:      "dice",
		Status:   mcomm.Status_Up,
		Langs:    langs,
		Grp:      2,
		Updated:  t,
	}, &gamep.WzGame{
		GameID:   103,
		GameName: "Mini-Roulette",
		Tag:      "mini-roulette",
		Status:   mcomm.Status_Up,
		Langs:    langs,
		Grp:      2,
		Updated:  t,
	}, &gamep.WzGame{
		GameID:   104,
		GameName: "Hilo",
		Tag:      "hi-lo",
		Status:   mcomm.Status_Up,
		Langs:    langs,
		Grp:      2,
		Updated:  t,
	}, &gamep.WzGame{
		GameID:   105,
		GameName: "Plinko",
		Tag:      "plinko",
		Status:   mcomm.Status_Up,
		Langs:    langs,
		Grp:      2,
		Updated:  t,
	}, &gamep.WzGame{
		GameID:   106,
		GameName: "Goal",
		Tag:      "goal",
		Status:   mcomm.Status_Up,
		Langs:    langs,
		Grp:      2,
		Updated:  t,
	}, &gamep.WzGame{
		GameID:   107,
		GameName: "Keno",
		Tag:      "keno",
		Status:   mcomm.Status_Up,
		Langs:    langs,
		Grp:      2,
		Updated:  t,
	}, &gamep.WzGame{
		GameID:   108,
		GameName: "Hotline",
		Tag:      "hotline",
		Status:   mcomm.Status_Up,
		Langs:    langs,
		Grp:      2,
		Updated:  t,
	}, &gamep.WzGame{
		GameID:   109,
		GameName: "Roulette",
		Tag:      "roulette",
		Status:   mcomm.Status_Up,
		Langs:    langs,
		Grp:      3,
		Updated:  t,
	})
	for _, game := range games {
		b, err1 := proto.Marshal(game)
		if err1 != nil {
			panic(err1)
		}
		_, err = etcdClient.Store(constant.CcBaseRoot+"/games/"+game.Tag, byteutil.SliceByteToString(b))
		if err != nil {
			panic(err)
		}
	}
}

func addMaintain() {
	_, err = etcdClient.Store(constant.CcCommRoot+"/mt", "")
	if err != nil {
		panic(err)
	}
}

func addGameInstants() {
	t := dateutil.UnixSecs()
	nodeTags := []string{"dev"}
	curr2GcId := map[int32]int64{1: 1000, 2: 1001}
	var insts []*gamep.GameInst
	insts = append(insts, &gamep.GameInst{
		InstID:    1000,
		InstName:  "Aviator",
		GameID:    100,
		GameTag:   "aviator",
		Status:    mcomm.Status_Up,
		Curr2GcID: curr2GcId,
		NodeTags:  nodeTags,
		Updated:   t,
	}, &gamep.GameInst{
		InstID:    1001,
		InstName:  "Mines",
		GameID:    101,
		GameTag:   "mines",
		Status:    mcomm.Status_Up,
		Curr2GcID: curr2GcId,
		NodeTags:  nodeTags,
		Updated:   t,
	}, &gamep.GameInst{
		InstID:    1002,
		InstName:  "Dice",
		GameID:    102,
		GameTag:   "dice",
		Status:    mcomm.Status_Up,
		Curr2GcID: curr2GcId,
		NodeTags:  nodeTags,
		Updated:   t,
	}, &gamep.GameInst{
		InstID:    1003,
		InstName:  "Mini-Roulette",
		GameID:    103,
		GameTag:   "mini-roulette",
		Status:    mcomm.Status_Up,
		Curr2GcID: curr2GcId,
		NodeTags:  nodeTags,
		Updated:   t,
	}, &gamep.GameInst{
		InstID:    1004,
		InstName:  "Hilo",
		GameID:    104,
		GameTag:   "hi-lo",
		Status:    mcomm.Status_Up,
		Curr2GcID: curr2GcId,
		NodeTags:  nodeTags,
		Updated:   t,
	}, &gamep.GameInst{
		InstID:    1005,
		InstName:  "Plinko",
		GameID:    105,
		GameTag:   "plinko",
		Status:    mcomm.Status_Up,
		Curr2GcID: curr2GcId,
		NodeTags:  nodeTags,
		Updated:   t,
	}, &gamep.GameInst{
		InstID:    1006,
		InstName:  "Goal",
		GameID:    106,
		GameTag:   "goal",
		Status:    mcomm.Status_Up,
		Curr2GcID: curr2GcId,
		NodeTags:  nodeTags,
		Updated:   t,
	}, &gamep.GameInst{
		InstID:    1007,
		InstName:  "Keno",
		GameID:    107,
		GameTag:   "keno",
		Status:    mcomm.Status_Up,
		Curr2GcID: curr2GcId,
		NodeTags:  nodeTags,
		Updated:   t,
	}, &gamep.GameInst{
		InstID:    1008,
		InstName:  "Hotline",
		GameID:    108,
		GameTag:   "hotline",
		Status:    mcomm.Status_Up,
		Curr2GcID: curr2GcId,
		NodeTags:  nodeTags,
		Updated:   t,
	})
	for _, v := range insts {
		b, err1 := proto.Marshal(v)
		if err1 != nil {
			panic(err1)
		}
		var key string
		if v.GameID == 100 {
			key = constant.CcInstanceAviator + "/" + v.GameTag + "_" + strconv.FormatInt(v.InstID, 10)
		} else {
			key = constant.CcInstanceG8 + "/" + v.GameTag + "_" + strconv.FormatInt(v.InstID, 10)
		}
		_, err = etcdClient.Store(key, byteutil.SliceByteToString(b))
		if err != nil {
			panic(err)
		}
	}
}

func addAgentGuest() {
	t := dateutil.UnixSecs()
	agent := &agentp.Agent{
		AgtID:      1,
		AgtKey:     "guest",
		AgtName:    "guest",
		StartTime:  1684886400,
		EndTime:    0,
		Status:     mcomm.Status_Up,
		ASect:      "abcdefghijklmnop",
		WalletType: mcomm.WalletType_DouWallet,
		CurrList:   map[string]int32{"USD": 1, "EUR": 2, "GOLD": 3},
		Conf:       &agentp.UiConfig{},
		Remark:     "guest",
		Updated:    t,
		Games: map[int64]*agentp.AgentGame{
			1000: {
				InstID:  1000,
				Guest:   true,
				Status:  mcomm.Status_Up,
				Conf:    &agentp.AgentGameConf{},
				Updated: t,
			},
			1001: {
				InstID:  1001,
				Guest:   true,
				Status:  mcomm.Status_Up,
				Conf:    &agentp.AgentGameConf{},
				Updated: t,
			},
			1002: {
				InstID:  1002,
				Guest:   true,
				Status:  mcomm.Status_Up,
				Conf:    &agentp.AgentGameConf{},
				Updated: t,
			},
			1003: {
				InstID:  1003,
				Guest:   true,
				Status:  mcomm.Status_Up,
				Conf:    &agentp.AgentGameConf{},
				Updated: t,
			},
			1004: {
				InstID:  1004,
				Guest:   true,
				Status:  mcomm.Status_Up,
				Conf:    &agentp.AgentGameConf{},
				Updated: t,
			},
			1005: {
				InstID:  1005,
				Guest:   true,
				Status:  mcomm.Status_Up,
				Conf:    &agentp.AgentGameConf{},
				Updated: t,
			},
			1006: {
				InstID:  1006,
				Guest:   true,
				Status:  mcomm.Status_Up,
				Conf:    &agentp.AgentGameConf{},
				Updated: t,
			},
			1007: {
				InstID:  1007,
				Guest:   true,
				Status:  mcomm.Status_Up,
				Conf:    &agentp.AgentGameConf{},
				Updated: t,
			},
			1008: {
				InstID:  1008,
				Guest:   true,
				Status:  mcomm.Status_Up,
				Conf:    &agentp.AgentGameConf{},
				Updated: t,
			},
			1009: {
				InstID:  1009,
				Guest:   true,
				Status:  mcomm.Status_Up,
				Conf:    &agentp.AgentGameConf{},
				Updated: t,
			},
		},
	}
	b, err1 := proto.Marshal(agent)
	if err1 != nil {
		panic(err1)
	}
	_, err = etcdClient.Store(constant.CcBaseRoot+"/agents/agent-1", byteutil.SliceByteToString(b))
	if err != nil {
		panic(err)
	}
}

func addAgent() {
	t := dateutil.UnixSecs()
	agent := &agentp.Agent{
		AgtID:      1000,
		AgtKey:     "demo",
		AgtName:    "demo",
		StartTime:  1684886400,
		EndTime:    1716508800,
		Status:     mcomm.Status_Up,
		ASect:      "abcdefghijklmnop",
		WalletType: mcomm.WalletType_DouWallet,
		CurrList:   map[string]int32{"USD": 1, "EUR": 2, "GOLD": 3},
		Conf:       &agentp.UiConfig{},
		Remark:     "test",
		Updated:    t,
		WhiteIP:    "all",
		Games: map[int64]*agentp.AgentGame{
			1000: {
				InstID:  1000,
				Guest:   true,
				Status:  mcomm.Status_Up,
				Conf:    &agentp.AgentGameConf{},
				Updated: t,
			},
			1001: {
				InstID:  1001,
				Guest:   true,
				Status:  mcomm.Status_Up,
				Conf:    &agentp.AgentGameConf{},
				Updated: t,
			},
			1002: {
				InstID:  1002,
				Guest:   true,
				Status:  mcomm.Status_Up,
				Conf:    &agentp.AgentGameConf{},
				Updated: t,
			},
			1003: {
				InstID:  1003,
				Guest:   true,
				Status:  mcomm.Status_Up,
				Conf:    &agentp.AgentGameConf{},
				Updated: t,
			},
			1004: {
				InstID:  1004,
				Guest:   true,
				Status:  mcomm.Status_Up,
				Conf:    &agentp.AgentGameConf{},
				Updated: t,
			},
			1005: {
				InstID:  1005,
				Guest:   true,
				Status:  mcomm.Status_Up,
				Conf:    &agentp.AgentGameConf{},
				Updated: t,
			},
			1006: {
				InstID:  1006,
				Guest:   true,
				Status:  mcomm.Status_Up,
				Conf:    &agentp.AgentGameConf{},
				Updated: t,
			},
			1007: {
				InstID:  1007,
				Guest:   true,
				Status:  mcomm.Status_Up,
				Conf:    &agentp.AgentGameConf{},
				Updated: t,
			},
			1008: {
				InstID:  1008,
				Guest:   true,
				Status:  mcomm.Status_Up,
				Conf:    &agentp.AgentGameConf{},
				Updated: t,
			},
			1009: {
				InstID:  1009,
				Guest:   true,
				Status:  mcomm.Status_Up,
				Conf:    &agentp.AgentGameConf{},
				Updated: t,
			},
		},
	}
	b, err1 := proto.Marshal(agent)
	if err1 != nil {
		panic(err1)
	}
	_, err = etcdClient.Store(constant.CcBaseRoot+"/agents/agent-1000", byteutil.SliceByteToString(b))
	if err != nil {
		panic(err)
	}
}

var (
	gCurr2GcId   = map[int32]int64{1: 1002, 2: 1003, 3: 1001}
	gAvCurr2GcId = map[int32]int64{1: 1005, 2: 1006, 3: 1004}
)

func DiceGameInstConf() {
	t := dateutil.UnixSecs()
	diceConf := &gkindp.DiceConfig{
		GameConfig: &gkindp.DiceGameConfig{
			ChancePrecision: 2,
			PayoutMin:       1.1,
			PayoutMax:       970,
			PayoutPrecision: 2,
			RollMin:         0.1,
			RollMax:         88.18,
			RollPrecision:   2,
		},
		NormalConfig: &gkindp.SharedConf{
			IsAutoBetFeatureEnabled:   true,
			IsLoginTimer:              false,
			IsClockVisible:            false,
			IsHideFreeBetsInUserMenu:  false,
			IsShowRtp:                 false,
			IsRuleUnfinishedGame:      false,
			IsGameNavigationEnabled:   true,
			AutoBetNumberOfRoundsList: []int32{3, 10, 25, 100, 200, 500},
			ActiveGame:                "dice",
			GameList:                  "dice,hotline,plinko,goal,hi-lo,mines,keno,mini-roulette",
			IsGameRulesHaveMaxWin:     false,
		},
		HouseEdge: 3,
	}
	diceConfigBin(diceConf)
	b1, e := proto.Marshal(diceConf)
	if e != nil {
		panic(e)
	}
	v := &gamep.GameInst{
		InstID:    1002,
		InstName:  "Dice",
		GameID:    102,
		GameTag:   "dice",
		Status:    mcomm.Status_Up,
		Curr2GcID: gCurr2GcId,
		Conf:      b1,
		Grp:       2,
		Updated:   t,
	}
	b, err1 := proto.Marshal(v)
	if err1 != nil {
		panic(err1)
	}
	key := constant.CcInstanceG8 + "/" + v.GameTag + "_" + strconv.FormatInt(v.InstID, 10)
	_, err = etcdClient.Store(key, byteutil.SliceByteToString(b))
	if err != nil {
		panic(err)
	}
}

func diceConfigBin(cfg *gkindp.DiceConfig) {
	xw := &sfs.XWriter{}
	defer xw.Reset()
	xw.WriteSfsObjectPre("gameConfig", uint16(3))
	xw.WriteSfsObjectPre("chance", uint16(1))
	xw.WriteIntS("precision", cfg.GameConfig.ChancePrecision)
	xw.WriteSfsObjectPre("payout", uint16(3))
	xw.WriteDoubleS("min", cfg.GameConfig.PayoutMin)
	xw.WriteDoubleS("max", cfg.GameConfig.PayoutMax)
	xw.WriteIntS("precision", cfg.GameConfig.PayoutPrecision)
	xw.WriteSfsObjectPre("roll", uint16(3))
	xw.WriteDoubleS("min", cfg.GameConfig.RollMin)
	xw.WriteDoubleS("max", cfg.GameConfig.RollMax)
	xw.WriteIntS("precision", cfg.GameConfig.RollPrecision)

	xw.WriteSfsObjectPre("config", uint16(18))
	xw.WriteBoolS("isAutoBetFeatureEnabled", cfg.NormalConfig.IsAutoBetFeatureEnabled)
	xw.WriteBoolS("isLoginTimer", cfg.NormalConfig.IsLoginTimer)
	xw.WriteBoolS("isClockVisible", cfg.NormalConfig.IsClockVisible)
	xw.WriteBoolS("isHideFreeBetsInUserMenu", cfg.NormalConfig.IsHideFreeBetsInUserMenu)
	xw.WriteBoolS("isShowRtp", cfg.NormalConfig.IsShowRtp)
	xw.WriteDoubleS("houseEdge", cfg.HouseEdge)
	xw.WriteBoolS("isGameNavigationEnabled", cfg.NormalConfig.IsGameNavigationEnabled)
	xw.WriteIntArrayS("autoBetNumberOfRoundsList", cfg.NormalConfig.AutoBetNumberOfRoundsList)
	xw.WriteStringS("activeGame", cfg.NormalConfig.ActiveGame)
	xw.WriteStringS("gameList", cfg.NormalConfig.GameList)
	xw.WriteBoolS("isGameRulesHaveMaxWin", cfg.NormalConfig.IsGameRulesHaveMaxWin)

	//xw.WriteDoubleArrayS("fastBets", cfg.FastBets)
	//xw.WriteStringS("currency", cfg.Currency)
	//xw.WriteDoubleS("maxBet", utils.CalcIntDiv100(cfg.MaxBet))
	//xw.WriteDoubleS("minBet", utils.CalcIntDiv100(cfg.MinBet))
	//xw.WriteIntS("betPrecision", cfg.BetPrecision)
	//xw.WriteDoubleS("defaultBetValue", utils.CalcIntDiv100(cfg.DefaultBetValue))
	//xw.WriteDoubleS("maxUserWin", utils.CalcIntDiv100(cfg.MaxUserWin))
	cfg.ConfigBin = append(cfg.ConfigBin, xw.Data()...)
}

func HotlineGameInstConf() {
	t := dateutil.UnixSecs()
	conf := &gkindp.HotLineConfig{
		GameConfig: &gkindp.HotlineGameConfig{
			Reg:    "2",
			RegRow: "4.125",
			HotRow: "1056",
			Hot:    "32",
		},
		NormalConfig: &gkindp.SharedConf{
			IsAutoBetFeatureEnabled:   true,
			IsLoginTimer:              false,
			IsClockVisible:            false,
			IsHideFreeBetsInUserMenu:  false,
			IsShowRtp:                 false,
			IsRuleUnfinishedGame:      false,
			IsGameNavigationEnabled:   true,
			AutoBetNumberOfRoundsList: []int32{3, 10, 25, 100, 200, 500},
			ActiveGame:                "hotline",
			GameList:                  "dice,hotline,plinko,goal,hi-lo,mines,keno,mini-roulette",
			IsGameRulesHaveMaxWin:     false,
		},
		HouseEdge: 3,
	}
	hotlineConfigBin(conf)
	b1, e := proto.Marshal(conf)
	if e != nil {
		panic(e)
	}
	v := &gamep.GameInst{
		InstID:    1008,
		InstName:  "Hotline",
		GameID:    108,
		GameTag:   "hotline",
		Status:    mcomm.Status_Up,
		Curr2GcID: gCurr2GcId,
		Conf:      b1,
		Grp:       2,
		Updated:   t,
	}
	b, err1 := proto.Marshal(v)
	if err1 != nil {
		panic(err1)
	}
	key := constant.CcInstanceG8 + "/" + v.GameTag + "_" + strconv.FormatInt(v.InstID, 10)
	_, err = etcdClient.Store(key, byteutil.SliceByteToString(b))
	if err != nil {
		panic(err)
	}
}

func hotlineConfigBin(cfg *gkindp.HotLineConfig) {
	xw := &sfs.XWriter{}
	defer xw.Reset()
	xw.WriteSfsObjectPre("gameConfig", uint16(1))
	xw.WriteSfsObjectPre("coefficient", uint16(4))
	xw.WriteStringS("reg", cfg.GameConfig.Reg)
	xw.WriteStringS("reg_row", cfg.GameConfig.RegRow)
	xw.WriteStringS("hot_row", cfg.GameConfig.HotRow)
	xw.WriteStringS("hot", cfg.GameConfig.Hot)

	xw.WriteSfsObjectPre("config", uint16(18))
	xw.WriteBoolS("isAutoBetFeatureEnabled", cfg.NormalConfig.IsAutoBetFeatureEnabled)
	xw.WriteBoolS("isLoginTimer", cfg.NormalConfig.IsLoginTimer)
	xw.WriteBoolS("isClockVisible", cfg.NormalConfig.IsClockVisible)
	xw.WriteBoolS("isHideFreeBetsInUserMenu", cfg.NormalConfig.IsHideFreeBetsInUserMenu)
	xw.WriteBoolS("isShowRtp", cfg.NormalConfig.IsShowRtp)
	xw.WriteDoubleS("houseEdge", cfg.HouseEdge)
	xw.WriteBoolS("isGameNavigationEnabled", cfg.NormalConfig.IsGameNavigationEnabled)
	xw.WriteIntArrayS("autoBetNumberOfRoundsList", cfg.NormalConfig.AutoBetNumberOfRoundsList)
	xw.WriteStringS("activeGame", cfg.NormalConfig.ActiveGame)
	xw.WriteStringS("gameList", cfg.NormalConfig.GameList)
	xw.WriteBoolS("isGameRulesHaveMaxWin", cfg.NormalConfig.IsGameRulesHaveMaxWin)

	//xw.WriteDoubleArrayS("fastBets", cfg.FastBets)
	//xw.WriteStringS("currency", cfg.Currency)
	//xw.WriteDoubleS("maxBet", utils.CalcIntDiv100(cfg.MaxBet))
	//xw.WriteDoubleS("minBet", utils.CalcIntDiv100(cfg.MinBet))
	//xw.WriteIntS("betPrecision", cfg.BetPrecision)
	//xw.WriteDoubleS("defaultBetValue", utils.CalcIntDiv100(cfg.DefaultBetValue))
	//xw.WriteDoubleS("maxUserWin", utils.CalcIntDiv100(cfg.MaxUserWin))
	cfg.ConfigBin = append(cfg.ConfigBin, xw.Data()...)
}

func KenoGameInstConf() {
	t := dateutil.UnixSecs()
	conf := &gkindp.KenoConfig{
		GameConfig: &gkindp.KenoGameConfig{
			Columns: 6,
			Rows:    6,
			SelMax:  10,
			Factors10: []*gkindp.KenoFactors{
				{Factors: []float64{3.49}},
				{Factors: []float64{1.5, 4.92}},
				{Factors: []float64{1, 2.3, 8.2}},
				{Factors: []float64{0.5, 1.82, 4.2, 21}},
				{Factors: []float64{0, 1.1, 3.75, 15, 35}},
				{Factors: []float64{0, 0.5, 2.9, 7.6, 18, 55}},
				{Factors: []float64{0, 0.25, 2.3, 4.1, 10, 31, 60}},
				{Factors: []float64{0, 0, 1.4, 2.8, 11.4, 28, 40, 70}},
				{Factors: []float64{0, 0, 1, 2.2, 6.1, 17, 25, 55, 85}},
				{Factors: []float64{0, 0, 1, 1.5, 3.3, 10.2, 25, 40, 75, 100}},
			},
		},
		NormalConfig: &gkindp.SharedConf{
			IsAutoBetFeatureEnabled:   true,
			IsLoginTimer:              false,
			IsClockVisible:            false,
			IsHideFreeBetsInUserMenu:  false,
			IsShowRtp:                 false,
			IsRuleUnfinishedGame:      false,
			IsGameNavigationEnabled:   true,
			AutoBetNumberOfRoundsList: []int32{3, 10, 25, 100, 200, 500},
			ActiveGame:                "keno",
			GameList:                  "dice,hotline,plinko,goal,hi-lo,mines,keno,mini-roulette",
			IsGameRulesHaveMaxWin:     false,
		},
		HouseEdge: 3,
	}
	kenoConfigBin(conf)
	b1, e := proto.Marshal(conf)
	if e != nil {
		panic(e)
	}
	v := &gamep.GameInst{
		InstID:    1007,
		InstName:  "Keno",
		GameID:    107,
		GameTag:   "keno",
		Status:    mcomm.Status_Up,
		Curr2GcID: gCurr2GcId,
		Conf:      b1,
		Grp:       2,
		Updated:   t,
	}
	b, err1 := proto.Marshal(v)
	if err1 != nil {
		panic(err1)
	}
	key := constant.CcInstanceG8 + "/" + v.GameTag + "_" + strconv.FormatInt(v.InstID, 10)
	_, err = etcdClient.Store(key, byteutil.SliceByteToString(b))
	if err != nil {
		panic(err)
	}
}

func kenoConfigBin(cfg *gkindp.KenoConfig) {
	xw := &sfs.XWriter{}
	defer xw.Reset()
	xw.WriteSfsObjectPre("gameConfig", uint16(1))
	xw.WriteSfsObjectPre("grid", uint16(3))
	xw.WriteIntS("columns", cfg.GameConfig.Columns)
	xw.WriteIntS("rows", cfg.GameConfig.Rows)
	xw.WriteSfsArrayPre("factors", uint16(10))
	for i := 0; i < 10; i++ {
		xw.WriteUByte(sfs.DoubleArray)
		xw.WriteUShort(uint16(len(cfg.GameConfig.Factors10[i].Factors)))
		for _, v := range cfg.GameConfig.Factors10[i].Factors {
			xw.WriteDouble(v)
		}
	}

	xw.WriteSfsObjectPre("config", uint16(18))
	xw.WriteBoolS("isAutoBetFeatureEnabled", cfg.NormalConfig.IsAutoBetFeatureEnabled)
	xw.WriteBoolS("isLoginTimer", cfg.NormalConfig.IsLoginTimer)
	xw.WriteBoolS("isClockVisible", cfg.NormalConfig.IsClockVisible)
	xw.WriteBoolS("isHideFreeBetsInUserMenu", cfg.NormalConfig.IsHideFreeBetsInUserMenu)
	xw.WriteBoolS("isShowRtp", cfg.NormalConfig.IsShowRtp)
	xw.WriteDoubleS("houseEdge", cfg.HouseEdge)
	xw.WriteBoolS("isGameNavigationEnabled", cfg.NormalConfig.IsGameNavigationEnabled)
	xw.WriteIntArrayS("autoBetNumberOfRoundsList", cfg.NormalConfig.AutoBetNumberOfRoundsList)
	xw.WriteStringS("activeGame", cfg.NormalConfig.ActiveGame)
	xw.WriteStringS("gameList", cfg.NormalConfig.GameList)
	xw.WriteBoolS("isGameRulesHaveMaxWin", cfg.NormalConfig.IsGameRulesHaveMaxWin)

	//xw.WriteDoubleArrayS("fastBets", cfg.FastBets)
	//xw.WriteStringS("currency", cfg.Currency)
	//xw.WriteDoubleS("maxBet", utils.CalcIntDiv100(cfg.MaxBet))
	//xw.WriteDoubleS("minBet", utils.CalcIntDiv100(cfg.MinBet))
	//xw.WriteIntS("betPrecision", cfg.BetPrecision)
	//xw.WriteDoubleS("defaultBetValue", utils.CalcIntDiv100(cfg.DefaultBetValue))
	//xw.WriteDoubleS("maxUserWin", utils.CalcIntDiv100(cfg.MaxUserWin))
	cfg.ConfigBin = append(cfg.ConfigBin, xw.Data()...)
}

func PlinkoGameInstConf() {
	t := dateutil.UnixSecs()
	conf := &gkindp.PlinkoConfig{
		GameConfig: &gkindp.PlinkoGameConfig{
			Pins: []int32{12, 14, 16},
			PinsPay: []*gkindp.PlinkoPinsPay{
				{
					Red:    []float64{141, 25, 8.1, 2.3, 0.7, 0.2, 0, 0.2, 0.7, 2.3, 8.1, 25, 141},
					Green:  []float64{11, 3.2, 1.6, 1.2, 1.1, 1, 0.5, 1, 1.1, 1.2, 1.6, 3.2, 11},
					Yellow: []float64{25, 8, 3.1, 1.7, 1.2, 0.7, 0.3, 0.7, 1.2, 1.7, 3.1, 8, 25},
				},
				{
					Red:    []float64{353, 49, 14, 5.3, 2.1, 0.5, 0.2, 0, 0.2, 0.5, 2.1, 5.3, 14, 49, 353},
					Green:  []float64{18, 3.2, 1.6, 1.3, 1.2, 1.1, 1, 0.5, 1, 1.1, 1.2, 1.3, 1.6, 3.2, 18},
					Yellow: []float64{55, 12, 5.6, 3.2, 1.6, 1, 0.7, 0.2, 0.7, 1, 1.6, 3.2, 5.6, 12, 55},
				},
				{
					Red:    []float64{555, 122, 26, 8.5, 3.5, 2, 0.5, 0.2, 0, 0.2, 0.5, 2, 3.5, 8.5, 26, 122, 555},
					Green:  []float64{35, 7.7, 2.5, 1.6, 1.3, 1.2, 1.1, 1, 0.4, 1, 1.1, 1.2, 1.3, 1.6, 2.5, 7.7, 35},
					Yellow: []float64{118, 61, 12, 4.5, 2.3, 1.2, 1, 0.7, 0.2, 0.7, 1, 1.2, 2.3, 4.5, 12, 61, 118},
				},
			},
		},
		NormalConfig: &gkindp.SharedConf{
			IsAutoBetFeatureEnabled:   true,
			IsLoginTimer:              false,
			IsClockVisible:            false,
			IsHideFreeBetsInUserMenu:  false,
			IsShowRtp:                 false,
			IsRuleUnfinishedGame:      false,
			IsGameNavigationEnabled:   true,
			AutoBetNumberOfRoundsList: []int32{3, 10, 25, 100, 200, 500},
			ActiveGame:                "plinko",
			GameList:                  "dice,hotline,plinko,goal,hi-lo,mines,keno,mini-roulette",
			IsGameRulesHaveMaxWin:     false,
		},
		HouseEdge: 3,
	}
	plinkoConfigBin(conf)
	b1, e := proto.Marshal(conf)
	if e != nil {
		panic(e)
	}
	v := &gamep.GameInst{
		InstID:    1005,
		InstName:  "Plinko",
		GameID:    105,
		GameTag:   "plinko",
		Status:    mcomm.Status_Up,
		Curr2GcID: gCurr2GcId,
		Conf:      b1,
		Grp:       2,
		Updated:   t,
	}
	b, err1 := proto.Marshal(v)
	if err1 != nil {
		panic(err1)
	}
	key := constant.CcInstanceG8 + "/" + v.GameTag + "_" + strconv.FormatInt(v.InstID, 10)
	_, err = etcdClient.Store(key, byteutil.SliceByteToString(b))
	if err != nil {
		panic(err)
	}
}

func plinkoConfigBin(cfg *gkindp.PlinkoConfig) {
	xw := &sfs.XWriter{}
	defer xw.Reset()
	xw.WriteSfsObjectPre("gameConfig", uint16(1))
	xw.WriteSfsObjectPre("multipliers", uint16(3))
	for i := 0; i < len(cfg.GameConfig.Pins); i++ {
		key := stringutil.ToString(cfg.GameConfig.Pins[i])
		xw.WriteSfsObjectPre(key, uint16(3))
		xw.WriteDoubleArrayS("red", cfg.GameConfig.PinsPay[i].Red)
		xw.WriteDoubleArrayS("green", cfg.GameConfig.PinsPay[i].Green)
		xw.WriteDoubleArrayS("yellow", cfg.GameConfig.PinsPay[i].Yellow)
	}

	xw.WriteSfsObjectPre("config", uint16(18))
	xw.WriteBoolS("isAutoBetFeatureEnabled", cfg.NormalConfig.IsAutoBetFeatureEnabled)
	xw.WriteBoolS("isLoginTimer", cfg.NormalConfig.IsLoginTimer)
	xw.WriteBoolS("isClockVisible", cfg.NormalConfig.IsClockVisible)
	xw.WriteBoolS("isHideFreeBetsInUserMenu", cfg.NormalConfig.IsHideFreeBetsInUserMenu)
	xw.WriteBoolS("isShowRtp", cfg.NormalConfig.IsShowRtp)
	xw.WriteDoubleS("houseEdge", cfg.HouseEdge)
	xw.WriteBoolS("isGameNavigationEnabled", cfg.NormalConfig.IsGameNavigationEnabled)
	xw.WriteIntArrayS("autoBetNumberOfRoundsList", cfg.NormalConfig.AutoBetNumberOfRoundsList)
	xw.WriteStringS("activeGame", cfg.NormalConfig.ActiveGame)
	xw.WriteStringS("gameList", cfg.NormalConfig.GameList)
	xw.WriteBoolS("isGameRulesHaveMaxWin", cfg.NormalConfig.IsGameRulesHaveMaxWin)

	//xw.WriteDoubleArrayS("fastBets", cfg.FastBets)
	//xw.WriteStringS("currency", cfg.Currency)
	//xw.WriteDoubleS("maxBet", utils.CalcIntDiv100(cfg.MaxBet))
	//xw.WriteDoubleS("minBet", utils.CalcIntDiv100(cfg.MinBet))
	//xw.WriteIntS("betPrecision", cfg.BetPrecision)
	//xw.WriteDoubleS("defaultBetValue", utils.CalcIntDiv100(cfg.DefaultBetValue))
	//xw.WriteDoubleS("maxUserWin", utils.CalcIntDiv100(cfg.MaxUserWin))
	cfg.ConfigBin = append(cfg.ConfigBin, xw.Data()...)
}

func RouletteGameInstConf() {
	t := dateutil.UnixSecs()
	conf := &gkindp.MiniRouletteConfig{
		GameConfig: &gkindp.RouletteGameConfig{
			TotalNum:           12,
			PayTableNumAmount1: 11.64,
			PayTableNumAmount2: 5.82,
			PayTableNumAmount4: 2.91,
			PayTableNumAmount6: 1.94,
			ChipsCost:          []float64{1, 10, 50, 100, 500, 1000, 10000},
			ChipEquals:         0.01,
			Red:                &gkindp.RouletteMN{Min: 10, Max: 10000},
			Total:              &gkindp.RouletteMN{Min: 10, Max: 10000},
			S:                  &gkindp.RouletteMN{Min: 10, Max: 10000},
			Even:               &gkindp.RouletteMN{Min: 10, Max: 10000},
			V:                  &gkindp.RouletteMN{Min: 10, Max: 10000},
			H:                  &gkindp.RouletteMN{Min: 10, Max: 10000},
			Half2:              &gkindp.RouletteMN{Min: 10, Max: 10000},
			Black:              &gkindp.RouletteMN{Min: 10, Max: 10000},
			Half1:              &gkindp.RouletteMN{Min: 10, Max: 10000},
			N:                  &gkindp.RouletteMN{Min: 10, Max: 10000},
			Odd:                &gkindp.RouletteMN{Min: 10, Max: 10000},
			Sectors: &gkindp.RouletteSectors{
				S: []*gkindp.SectorVals{
					{Vals: []int32{1, 2, 3, 4}},
					{Vals: []int32{3, 4, 5, 6}},
					{Vals: []int32{5, 6, 7, 8}},
					{Vals: []int32{7, 8, 9, 10}},
					{Vals: []int32{9, 10, 11, 12}},
				},
				SLen: 5,
				H: []*gkindp.SectorVals{
					{Vals: []int32{1, 2}},
					{Vals: []int32{3, 4}},
					{Vals: []int32{5, 6}},
					{Vals: []int32{7, 8}},
					{Vals: []int32{9, 10}},
					{Vals: []int32{11, 12}},
				},
				HLen: 6,
				V: []*gkindp.SectorVals{
					{Vals: []int32{1, 3}},
					{Vals: []int32{2, 4}},
					{Vals: []int32{3, 5}},
					{Vals: []int32{4, 6}},
					{Vals: []int32{5, 7}},
					{Vals: []int32{6, 8}},
					{Vals: []int32{7, 9}},
					{Vals: []int32{8, 10}},
					{Vals: []int32{9, 11}},
					{Vals: []int32{10, 12}},
				},
				VLen:  10,
				Half1: &gkindp.SectorVals{Vals: []int32{1, 2, 3, 4, 5, 6}},
				Even:  &gkindp.SectorVals{Vals: []int32{2, 4, 6, 8, 10, 12}},
				Black: &gkindp.SectorVals{Vals: []int32{2, 4, 6, 7, 9, 11}},
				Red:   &gkindp.SectorVals{Vals: []int32{1, 3, 5, 8, 10, 12}},
				Odd:   &gkindp.SectorVals{Vals: []int32{1, 3, 5, 7, 9, 11}},
				Half2: &gkindp.SectorVals{Vals: []int32{7, 8, 9, 10, 11, 12}},
			},
		},
		NormalConfig: &gkindp.SharedConf{
			IsAutoBetFeatureEnabled:   true,
			IsLoginTimer:              false,
			IsClockVisible:            false,
			IsHideFreeBetsInUserMenu:  false,
			IsShowRtp:                 false,
			IsRuleUnfinishedGame:      false,
			IsGameNavigationEnabled:   true,
			AutoBetNumberOfRoundsList: []int32{3, 10, 25, 100, 200, 500},
			ActiveGame:                "mini-roulette",
			GameList:                  "dice,hotline,plinko,goal,hi-lo,mines,keno,mini-roulette",
			IsGameRulesHaveMaxWin:     false,
		},
		HouseEdge: 3,
	}
	rouletteConfigBin(conf)
	b1, e := proto.Marshal(conf)
	if e != nil {
		panic(e)
	}
	v := &gamep.GameInst{
		InstID:    1003,
		InstName:  "Mini-Roulette",
		GameID:    103,
		GameTag:   "mini-roulette",
		Status:    mcomm.Status_Up,
		Curr2GcID: gCurr2GcId,
		Conf:      b1,
		Grp:       2,
		Updated:   t,
	}
	b, err1 := proto.Marshal(v)
	if err1 != nil {
		panic(err1)
	}
	key := constant.CcInstanceG8 + "/" + v.GameTag + "_" + strconv.FormatInt(v.InstID, 10)
	_, err = etcdClient.Store(key, byteutil.SliceByteToString(b))
	if err != nil {
		panic(err)
	}
}

func rouletteConfigBin(cfg *gkindp.MiniRouletteConfig) {
	xw := &sfs.XWriter{}
	defer xw.Reset()
	xw.WriteSfsObjectPre("gameConfig", uint16(4))
	xw.WriteSfsObjectPre("payTable", uint16(4))
	xw.WriteDoubleS("numAmount6", cfg.GameConfig.PayTableNumAmount6)
	xw.WriteDoubleS("numAmount2", cfg.GameConfig.PayTableNumAmount2)
	xw.WriteDoubleS("numAmount4", cfg.GameConfig.PayTableNumAmount4)
	xw.WriteDoubleS("numAmount1", cfg.GameConfig.PayTableNumAmount1)
	xw.WriteDoubleArrayS("chipsCost", cfg.GameConfig.ChipsCost)
	xw.WriteDoubleS("chipEquals", cfg.GameConfig.ChipEquals)
	xw.WriteSfsObjectPre("limits", uint16(11))
	xw.WriteSfsObjectPre("red", uint16(2))
	xw.WriteIntS("min", int32(cfg.GameConfig.Red.Min))
	xw.WriteIntS("max", int32(cfg.GameConfig.Red.Max))
	xw.WriteSfsObjectPre("total", uint16(2))
	xw.WriteIntS("min", int32(cfg.GameConfig.Total.Min))
	xw.WriteIntS("max", int32(cfg.GameConfig.Total.Max))
	xw.WriteSfsObjectPre("s", uint16(2))
	xw.WriteIntS("min", int32(cfg.GameConfig.S.Min))
	xw.WriteIntS("max", int32(cfg.GameConfig.S.Max))
	xw.WriteSfsObjectPre("even", uint16(2))
	xw.WriteIntS("min", int32(cfg.GameConfig.Even.Min))
	xw.WriteIntS("max", int32(cfg.GameConfig.Even.Max))
	xw.WriteSfsObjectPre("v", uint16(2))
	xw.WriteIntS("min", int32(cfg.GameConfig.V.Min))
	xw.WriteIntS("max", int32(cfg.GameConfig.V.Max))
	xw.WriteSfsObjectPre("h", uint16(2))
	xw.WriteIntS("min", int32(cfg.GameConfig.H.Min))
	xw.WriteIntS("max", int32(cfg.GameConfig.H.Max))
	xw.WriteSfsObjectPre("half2", uint16(2))
	xw.WriteIntS("min", int32(cfg.GameConfig.Half2.Min))
	xw.WriteIntS("max", int32(cfg.GameConfig.Half2.Max))
	xw.WriteSfsObjectPre("black", uint16(2))
	xw.WriteIntS("min", int32(cfg.GameConfig.Black.Min))
	xw.WriteIntS("max", int32(cfg.GameConfig.Black.Max))
	xw.WriteSfsObjectPre("half1", uint16(2))
	xw.WriteIntS("min", int32(cfg.GameConfig.Half1.Min))
	xw.WriteIntS("max", int32(cfg.GameConfig.Half1.Max))
	xw.WriteSfsObjectPre("n", uint16(2))
	xw.WriteIntS("min", int32(cfg.GameConfig.N.Min))
	xw.WriteIntS("max", int32(cfg.GameConfig.N.Max))
	xw.WriteSfsObjectPre("odd", uint16(2))
	xw.WriteIntS("min", int32(cfg.GameConfig.Odd.Min))
	xw.WriteIntS("max", int32(cfg.GameConfig.Odd.Max))

	xw.WriteSfsObjectPre("config", uint16(16))
	xw.WriteBoolS("isAutoBetFeatureEnabled", cfg.NormalConfig.IsAutoBetFeatureEnabled)
	xw.WriteBoolS("isLoginTimer", cfg.NormalConfig.IsLoginTimer)
	xw.WriteBoolS("isClockVisible", cfg.NormalConfig.IsClockVisible)
	xw.WriteBoolS("isHideFreeBetsInUserMenu", cfg.NormalConfig.IsHideFreeBetsInUserMenu)
	xw.WriteBoolS("isShowRtp", cfg.NormalConfig.IsShowRtp)
	xw.WriteDoubleS("houseEdge", cfg.HouseEdge)
	xw.WriteBoolS("isGameNavigationEnabled", cfg.NormalConfig.IsGameNavigationEnabled)
	xw.WriteIntArrayS("autoBetNumberOfRoundsList", cfg.NormalConfig.AutoBetNumberOfRoundsList)
	xw.WriteStringS("activeGame", cfg.NormalConfig.ActiveGame)
	xw.WriteStringS("gameList", cfg.NormalConfig.GameList)
	xw.WriteBoolS("isGameRulesHaveMaxWin", cfg.NormalConfig.IsGameRulesHaveMaxWin)

	//xw.WriteStringS("currency", cfg.Currency)
	//xw.WriteDoubleS("maxBet", utils.CalcIntDiv100(cfg.MaxBet))
	//xw.WriteDoubleS("minBet", utils.CalcIntDiv100(cfg.MinBet))
	//xw.WriteIntS("betPrecision", cfg.BetPrecision)
	//xw.WriteDoubleS("maxUserWin", utils.CalcIntDiv100(cfg.MaxUserWin))
	cfg.ConfigBin = append(cfg.ConfigBin, xw.Data()...)
}

func HiloGameInstConf() {
	t := dateutil.UnixSecs()
	conf := &gkindp.HiLoConfig{
		NormalConfig: &gkindp.SharedConf{
			IsAutoBetFeatureEnabled:   true,
			IsLoginTimer:              false,
			IsClockVisible:            false,
			IsHideFreeBetsInUserMenu:  false,
			IsShowRtp:                 false,
			IsRuleUnfinishedGame:      false,
			IsGameNavigationEnabled:   true,
			AutoBetNumberOfRoundsList: []int32{3, 10, 25, 100, 200, 500},
			ActiveGame:                "hi-lo",
			GameList:                  "dice,hotline,plinko,goal,hi-lo,mines,keno,mini-roulette",
			IsGameRulesHaveMaxWin:     false,
		},
		HouseEdge: 3,
	}
	hiloConfigBin(conf)
	b1, e := proto.Marshal(conf)
	if e != nil {
		panic(e)
	}
	v := &gamep.GameInst{
		InstID:    1004,
		InstName:  "Hilo",
		GameID:    104,
		GameTag:   "hi-lo",
		Status:    mcomm.Status_Up,
		Curr2GcID: gCurr2GcId,
		Conf:      b1,
		Grp:       2,
		Updated:   t,
	}
	b, err1 := proto.Marshal(v)
	if err1 != nil {
		panic(err1)
	}
	key := constant.CcInstanceG8 + "/" + v.GameTag + "_" + strconv.FormatInt(v.InstID, 10)
	_, err = etcdClient.Store(key, byteutil.SliceByteToString(b))
	if err != nil {
		panic(err)
	}
}

func hiloConfigBin(cfg *gkindp.HiLoConfig) {
	xw := &sfs.XWriter{}
	defer xw.Reset()
	xw.WriteSfsObjectPre("config", uint16(18))
	xw.WriteBoolS("isAutoBetFeatureEnabled", cfg.NormalConfig.IsAutoBetFeatureEnabled)
	xw.WriteBoolS("isLoginTimer", cfg.NormalConfig.IsLoginTimer)
	xw.WriteBoolS("isClockVisible", cfg.NormalConfig.IsClockVisible)
	xw.WriteBoolS("isHideFreeBetsInUserMenu", cfg.NormalConfig.IsHideFreeBetsInUserMenu)
	xw.WriteBoolS("isShowRtp", cfg.NormalConfig.IsShowRtp)
	xw.WriteDoubleS("houseEdge", cfg.HouseEdge)
	xw.WriteBoolS("isGameNavigationEnabled", cfg.NormalConfig.IsGameNavigationEnabled)
	xw.WriteIntArrayS("autoBetNumberOfRoundsList", cfg.NormalConfig.AutoBetNumberOfRoundsList)
	xw.WriteStringS("activeGame", cfg.NormalConfig.ActiveGame)
	xw.WriteStringS("gameList", cfg.NormalConfig.GameList)
	xw.WriteBoolS("isGameRulesHaveMaxWin", cfg.NormalConfig.IsGameRulesHaveMaxWin)

	//xw.WriteDoubleArrayS("fastBets", cfg.FastBets)
	//xw.WriteStringS("currency", cfg.Currency)
	//xw.WriteDoubleS("maxBet", utils.CalcIntDiv100(cfg.MaxBet))
	//xw.WriteDoubleS("minBet", utils.CalcIntDiv100(cfg.MinBet))
	//xw.WriteIntS("betPrecision", cfg.BetPrecision)
	//xw.WriteDoubleS("defaultBetValue", utils.CalcIntDiv100(cfg.DefaultBetValue))
	//xw.WriteDoubleS("maxUserWin", utils.CalcIntDiv100(cfg.MaxUserWin))
	cfg.ConfigBin = append(cfg.ConfigBin, xw.Data()...)
}

func GoalGameInstConf() {
	t := dateutil.UnixSecs()
	conf := &gkindp.GoalConfig{
		GameConfig: &gkindp.GoalGameConfig{
			CoeffMd: []float64{1.29, 1.72, 2.29, 3.06, 4.08, 5.45, 7.26},
			CoeffSm: []float64{1.45, 2.18, 3.27, 4.91},
			CoeffLg: []float64{1.21, 1.51, 1.89, 2.36, 2.96, 3.7, 4.62, 5.78, 7.22, 9.03},
			Sm:      &gkindp.GoalRowCol{Row: 3, Col: 4},
			Md:      &gkindp.GoalRowCol{Row: 4, Col: 7},
			Lg:      &gkindp.GoalRowCol{Row: 5, Col: 10},
		},
		NormalConfig: &gkindp.SharedConf{
			IsAutoBetFeatureEnabled:   true,
			IsLoginTimer:              false,
			IsClockVisible:            false,
			IsHideFreeBetsInUserMenu:  false,
			IsShowRtp:                 false,
			IsRuleUnfinishedGame:      false,
			IsGameNavigationEnabled:   true,
			AutoBetNumberOfRoundsList: []int32{3, 10, 25, 100, 200, 500},
			ActiveGame:                "goal",
			GameList:                  "dice,hotline,plinko,goal,hi-lo,mines,keno,mini-roulette",
			IsGameRulesHaveMaxWin:     false,
		},
		HouseEdge: 3,
	}
	goalConfigBin(conf)
	b1, e := proto.Marshal(conf)
	if e != nil {
		panic(e)
	}
	v := &gamep.GameInst{
		InstID:    1006,
		InstName:  "Goal",
		GameID:    106,
		GameTag:   "goal",
		Status:    mcomm.Status_Up,
		Curr2GcID: gCurr2GcId,
		Conf:      b1,
		Grp:       2,
		Updated:   t,
	}
	b, err1 := proto.Marshal(v)
	if err1 != nil {
		panic(err1)
	}
	key := constant.CcInstanceG8 + "/" + v.GameTag + "_" + strconv.FormatInt(v.InstID, 10)
	_, err = etcdClient.Store(key, byteutil.SliceByteToString(b))
	if err != nil {
		panic(err)
	}
}

func goalConfigBin(cfg *gkindp.GoalConfig) {
	xw := &sfs.XWriter{}
	defer xw.Reset()
	xw.WriteSfsObjectPre("gameConfig", uint16(1))
	xw.WriteSfsObjectPre("coefficients", uint16(3))
	xw.WriteDoubleArrayS("md", cfg.GameConfig.CoeffMd)
	xw.WriteDoubleArrayS("sm", cfg.GameConfig.CoeffSm)
	xw.WriteDoubleArrayS("lg", cfg.GameConfig.CoeffLg)

	xw.WriteSfsObjectPre("config", uint16(18))
	xw.WriteBoolS("isAutoBetFeatureEnabled", cfg.NormalConfig.IsAutoBetFeatureEnabled)
	xw.WriteBoolS("isLoginTimer", cfg.NormalConfig.IsLoginTimer)
	xw.WriteBoolS("isClockVisible", cfg.NormalConfig.IsClockVisible)
	xw.WriteBoolS("isHideFreeBetsInUserMenu", cfg.NormalConfig.IsHideFreeBetsInUserMenu)
	xw.WriteBoolS("isShowRtp", cfg.NormalConfig.IsShowRtp)
	xw.WriteDoubleS("houseEdge", cfg.HouseEdge)
	xw.WriteBoolS("isGameNavigationEnabled", cfg.NormalConfig.IsGameNavigationEnabled)
	xw.WriteIntArrayS("autoBetNumberOfRoundsList", cfg.NormalConfig.AutoBetNumberOfRoundsList)
	xw.WriteStringS("activeGame", cfg.NormalConfig.ActiveGame)
	xw.WriteStringS("gameList", cfg.NormalConfig.GameList)
	xw.WriteBoolS("isGameRulesHaveMaxWin", cfg.NormalConfig.IsGameRulesHaveMaxWin)

	//xw.WriteDoubleArrayS("fastBets", cfg.FastBets)
	//xw.WriteStringS("currency", cfg.Currency)
	//xw.WriteDoubleS("maxBet", utils.CalcIntDiv100(cfg.MaxBet))
	//xw.WriteDoubleS("minBet", utils.CalcIntDiv100(cfg.MinBet))
	//xw.WriteIntS("betPrecision", cfg.BetPrecision)
	//xw.WriteDoubleS("defaultBetValue", utils.CalcIntDiv100(cfg.DefaultBetValue))
	//xw.WriteDoubleS("maxUserWin", utils.CalcIntDiv100(cfg.MaxUserWin))
	cfg.ConfigBin = append(cfg.ConfigBin, xw.Data()...)
}

func MinesGameInstConf() {
	t := dateutil.UnixSecs()
	conf := &gkindp.MinesConfig{
		DefaultMinesAmount: 3,
		NormalConfig: &gkindp.SharedConf{
			IsAutoBetFeatureEnabled:   true,
			IsLoginTimer:              false,
			IsClockVisible:            false,
			IsHideFreeBetsInUserMenu:  false,
			IsShowRtp:                 false,
			IsRuleUnfinishedGame:      false,
			IsGameNavigationEnabled:   true,
			AutoBetNumberOfRoundsList: []int32{3, 10, 25, 100, 200, 500},
			ActiveGame:                "mines",
			GameList:                  "dice,hotline,plinko,goal,hi-lo,mines,keno,mini-roulette",
			IsGameRulesHaveMaxWin:     false,
		},
		HouseEdge: 3,
	}
	minesConfigBin(conf)
	b1, e := proto.Marshal(conf)
	if e != nil {
		panic(e)
	}
	v := &gamep.GameInst{
		InstID:    1001,
		InstName:  "Mines",
		GameID:    101,
		GameTag:   "mines",
		Status:    mcomm.Status_Up,
		Curr2GcID: gCurr2GcId,
		Conf:      b1,
		Grp:       2,
		Updated:   t,
	}
	b, err1 := proto.Marshal(v)
	if err1 != nil {
		panic(err1)
	}
	key := constant.CcInstanceG8 + "/" + v.GameTag + "_" + strconv.FormatInt(v.InstID, 10)
	_, err = etcdClient.Store(key, byteutil.SliceByteToString(b))
	if err != nil {
		panic(err)
	}
}

func minesConfigBin(cfg *gkindp.MinesConfig) {
	xw := &sfs.XWriter{}
	defer xw.Reset()
	xw.WriteSfsObjectPre("gameConfig", uint16(1))
	xw.WriteIntS("defaultMinesAmount", cfg.DefaultMinesAmount)

	xw.WriteSfsObjectPre("config", uint16(18))
	xw.WriteBoolS("isAutoBetFeatureEnabled", cfg.NormalConfig.IsAutoBetFeatureEnabled)
	xw.WriteBoolS("isLoginTimer", cfg.NormalConfig.IsLoginTimer)
	xw.WriteBoolS("isClockVisible", cfg.NormalConfig.IsClockVisible)
	xw.WriteBoolS("isHideFreeBetsInUserMenu", cfg.NormalConfig.IsHideFreeBetsInUserMenu)
	xw.WriteBoolS("isShowRtp", cfg.NormalConfig.IsShowRtp)
	xw.WriteDoubleS("houseEdge", cfg.HouseEdge)
	xw.WriteBoolS("isGameNavigationEnabled", cfg.NormalConfig.IsGameNavigationEnabled)
	xw.WriteIntArrayS("autoBetNumberOfRoundsList", cfg.NormalConfig.AutoBetNumberOfRoundsList)
	xw.WriteStringS("activeGame", cfg.NormalConfig.ActiveGame)
	xw.WriteStringS("gameList", cfg.NormalConfig.GameList)
	xw.WriteBoolS("isGameRulesHaveMaxWin", cfg.NormalConfig.IsGameRulesHaveMaxWin)

	//xw.WriteDoubleArrayS("fastBets", cfg.FastBets)
	//xw.WriteStringS("currency", cfg.Currency)
	//xw.WriteDoubleS("maxBet", utils.CalcIntDiv100(cfg.MaxBet))
	//xw.WriteDoubleS("minBet", utils.CalcIntDiv100(cfg.MinBet))
	//xw.WriteIntS("betPrecision", cfg.BetPrecision)
	//xw.WriteDoubleS("defaultBetValue", utils.CalcIntDiv100(cfg.DefaultBetValue))
	//xw.WriteDoubleS("maxUserWin", utils.CalcIntDiv100(cfg.MaxUserWin))
	cfg.ConfigBin = append(cfg.ConfigBin, xw.Data()...)
}

func AviatorGameInstConf() {
	t := dateutil.UnixSecs()
	conf := &aviatorp.AviatorConfig{
		GameConfig: &aviatorp.AviatorGameConfig{
			MultiplierPrecision: 2,
			FullBetTime:         5000,
			ReturnToPlayer:      97,
		},
		NormalConfig: &aviatorp.NormalConf{
			IsAutoBetFeatureEnabled:      true,
			IsLoginTimer:                 false,
			IsClockVisible:               false,
			IsMultipleBetsEnabled:        true,
			QuickHelp:                    true,
			IsOperatorInGroup:            true,
			DecreaseOrExceedStopPointReq: true,
			IsFreeBetsEnabled:            false,
			IsGameRulesHaveMaxWin:        false,
			AdditionalOperatorData:       false,
			BackToHomeActionType:         "navigate",
			IsActiveGameFocused:          false,
			AccountHistoryActionType:     "navigate",
			NumberOfRounds:               []int32{10, 20, 50, 100},
		},
		HouseEdge:      3,
		Notifiers:      3,
		NotifyChanSize: 256,
	}
	aviatorConfigBin(conf)
	b1, e := proto.Marshal(conf)
	if e != nil {
		panic(e)
	}
	v := &gamep.GameInst{
		InstID:    1000,
		InstName:  "Aviator",
		GameID:    100,
		GameTag:   "aviator",
		Status:    mcomm.Status_Up,
		Curr2GcID: gAvCurr2GcId,
		Conf:      b1,
		Grp:       1,
		Updated:   t,
	}
	b, err1 := proto.Marshal(v)
	if err1 != nil {
		panic(err1)
	}
	key := constant.CcInstanceAviator + "/" + v.GameTag + "_" + strconv.FormatInt(v.InstID, 10)
	_, err = etcdClient.Store(key, byteutil.SliceByteToString(b))
	if err != nil {
		panic(err)
	}
}

func aviatorConfigBin(cfg *aviatorp.AviatorConfig) {
	xw := &sfs.XWriter{}
	defer xw.Reset()
	xw.WriteStringS("casinoMainPageLink", "")
	xw.WriteStringS("depositLink", "")
	xw.WriteStringS("logOutLink", "")

	xw.WriteSfsObjectPre("config", uint16(27))
	xw.WriteBoolS("isAutoBetFeatureEnabled", cfg.NormalConfig.IsAutoBetFeatureEnabled)
	xw.WriteIntS("multiplierPrecision", cfg.GameConfig.MultiplierPrecision)
	xw.WriteBoolS("isMultipleBetsEnabled", cfg.NormalConfig.IsMultipleBetsEnabled)
	xw.WriteBoolS("isLoginTimer", cfg.NormalConfig.IsLoginTimer)
	xw.WriteBoolS("isClockVisible", cfg.NormalConfig.IsClockVisible)
	xw.WriteBoolS("quickHelp", cfg.NormalConfig.QuickHelp)
	xw.WriteBoolS("isOperatorInGroup", cfg.NormalConfig.IsOperatorInGroup)

	xw.WriteSfsObjectPre("autoBetOptions", uint16(2))
	xw.WriteBoolS("decreaseOrExceedStopPointReq", cfg.NormalConfig.DecreaseOrExceedStopPointReq)
	xw.WriteIntArrayS("numberOfRounds", cfg.NormalConfig.NumberOfRounds)

	xw.WriteBoolS("isFreeBetsEnabled", cfg.NormalConfig.IsFreeBetsEnabled)
	xw.WriteBoolS("isGameRulesHaveMaxWin", cfg.NormalConfig.IsGameRulesHaveMaxWin)
	xw.WriteBoolS("additionalOperatorData", cfg.NormalConfig.AdditionalOperatorData)
	xw.WriteStringS("backToHomeActionType", cfg.NormalConfig.BackToHomeActionType)
	xw.WriteBoolS("isActiveGameFocused", cfg.NormalConfig.IsActiveGameFocused)
	xw.WriteLongS("fullBetTime", 5000)
	xw.WriteIntS("returnToPlayer", cfg.GameConfig.ReturnToPlayer)
	xw.WriteDoubleS("houseEdge", cfg.HouseEdge)
	xw.WriteStringS("accountHistoryActionType", cfg.NormalConfig.AccountHistoryActionType)
	xw.WriteSfsObjectPre("chat", uint16(0))

	//xw.WriteDoubleS("minBet", utils.CalcIntDiv100(cfg.MinBet))
	//xw.WriteDoubleS("maxBet", utils.CalcIntDiv100(cfg.MaxBet))
	//xw.WriteIntS("betPrecision", cfg.BetPrecision)
	//xw.WriteDoubleS("betInputStep", utils.CalcIntDiv100(cfg.BetInputStep))

	//xw.WriteSfsObjectPre("autoCashOut", uint16(3))
	//xw.WriteDoubleS("minValue", utils.CalcIntDiv100(cfg.AutoCashOut.MinValue))
	//xw.WriteDoubleS("maxValue", utils.CalcIntDiv100(cfg.AutoCashOut.MaxValue))
	//xw.WriteDoubleS("defaultValue", utils.CalcIntDiv100(cfg.AutoCashOut.DefaultValue))

	//xw.WriteStringS("currency", cfg.Currency)
	//xw.WriteDoubleS("defaultBetValue", utils.CalcIntDiv100(cfg.DefaultBetValue))
	//xw.WriteDoubleS("maxUserWin", utils.CalcIntDiv100(cfg.MaxUserWin))
	//xw.WriteIntArrayS("betOptions", cfg.BetOptions)
	cfg.ConfigBin = append(cfg.ConfigBin, xw.Data()...)
}

func RouletteBigGameInstConf() {
	t := dateutil.UnixSecs()
	conf := &roulettep.RouletteConfig{
		GameConfig: &roulettep.RouletteGameConfig{
			TotalNum:   38,
			Items:      []string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "00"},
			ChipsCost:  []float64{1, 10, 50, 100, 500, 1000, 10000},
			ChipEquals: 1,
			Rate:       3,
			Total:      &roulettep.RouletteU{Min: 10, Max: 10000},
			Red: &roulettep.RouletteU{
				Min:  10,
				Max:  10000,
				Odds: 2,
				Nums: &roulettep.SectorVals{Vals: []string{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18"}},
			},
			Green: &roulettep.RouletteU{
				Min:  10,
				Max:  10000,
				Odds: 18,
				Nums: &roulettep.SectorVals{Vals: []string{"0", "00"}},
			},
			Black: &roulettep.RouletteU{
				Min:  10,
				Max:  10000,
				Odds: 2,
				Nums: &roulettep.SectorVals{Vals: []string{"19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36"}},
			},
			A3: &roulettep.RouletteU{
				Min:  10,
				Max:  10000,
				Odds: 3,
				Nums: &roulettep.SectorVals{Vals: []string{"20", "16", "32", "5", "35", "3", "34", "14", "0", "28", "15", "36"}},
			},
			A1: &roulettep.RouletteU{
				Min:  10,
				Max:  10000,
				Odds: 3,
				Nums: &roulettep.SectorVals{Vals: []string{"17", "25", "6", "00", "22", "7", "19", "1", "31", "11", "24", "18"}},
			},
			A2: &roulettep.RouletteU{
				Min:  10,
				Max:  10000,
				Odds: 3,
				Nums: &roulettep.SectorVals{Vals: []string{"12", "27", "8", "33", "13", "30", "9", "26", "4", "23", "10", "21"}},
			},
			A4: &roulettep.RouletteU{
				Min:  10,
				Max:  10000,
				Odds: 18,
				Nums: &roulettep.SectorVals{Vals: []string{"2", "29"}},
			},
			N: &roulettep.RouletteU{
				Min:  10,
				Max:  10000,
				Odds: 36,
			},
		},
		IsAutoBetFeatureEnabled:   true,
		IsLoginTimer:              false,
		IsClockVisible:            false,
		IsHideFreeBetsInUserMenu:  false,
		IsShowRtp:                 false,
		IsRuleUnfinishedGame:      false,
		IsGameNavigationEnabled:   true,
		AutoBetNumberOfRoundsList: []int32{3, 10, 25, 100, 200, 500},
		ActiveGame:                "roulette",
		IsGameRulesHaveMaxWin:     false,
		HouseEdge:                 3,
		Notifiers:                 3,
		NotifyChanSize:            256,
	}
	rouletteBigConfigBin(conf)
	b1, e := proto.Marshal(conf)
	if e != nil {
		panic(e)
	}
	v := &gamep.GameInst{
		InstID:    1009,
		InstName:  "Roulette",
		GameID:    109,
		GameTag:   "roulette",
		Status:    mcomm.Status_Up,
		Curr2GcID: gCurr2GcId,
		Conf:      b1,
		Grp:       3,
		Updated:   t,
	}
	b, err1 := proto.Marshal(v)
	if err1 != nil {
		panic(err1)
	}
	key := constant.CcInstanceRoulette + "/" + v.GameTag + "_" + strconv.FormatInt(v.InstID, 10)
	_, err = etcdClient.Store(key, byteutil.SliceByteToString(b))
	if err != nil {
		panic(err)
	}
}

func rouletteBigConfigBin(cfg *roulettep.RouletteConfig) {
	xw := &sfs.XWriter{}
	defer xw.Reset()
	xw.WriteSfsObjectPre("gameConfig", uint16(4))
	xw.WriteDoubleS("rate", cfg.GameConfig.Rate)
	xw.WriteDoubleArrayS("chipsCost", cfg.GameConfig.ChipsCost)
	xw.WriteDoubleS("chipEquals", cfg.GameConfig.ChipEquals)
	xw.WriteSfsObjectPre("limits", uint16(9))
	xw.WriteSfsObjectPre("total", uint16(2))
	xw.WriteIntS("min", int32(cfg.GameConfig.Total.Min))
	xw.WriteIntS("max", int32(cfg.GameConfig.Total.Max))

	xw.WriteSfsObjectPre("red", uint16(3))
	xw.WriteIntS("min", int32(cfg.GameConfig.Red.Min))
	xw.WriteIntS("max", int32(cfg.GameConfig.Red.Max))
	xw.WriteDoubleS("odds", cfg.GameConfig.Red.Odds)

	xw.WriteSfsObjectPre("black", uint16(3))
	xw.WriteIntS("min", int32(cfg.GameConfig.Black.Min))
	xw.WriteIntS("max", int32(cfg.GameConfig.Black.Max))
	xw.WriteDoubleS("odds", cfg.GameConfig.Black.Odds)

	xw.WriteSfsObjectPre("green", uint16(3))
	xw.WriteIntS("min", int32(cfg.GameConfig.Green.Min))
	xw.WriteIntS("max", int32(cfg.GameConfig.Green.Max))
	xw.WriteDoubleS("odds", cfg.GameConfig.Green.Odds)

	xw.WriteSfsObjectPre("a1", uint16(3))
	xw.WriteIntS("min", int32(cfg.GameConfig.A1.Min))
	xw.WriteIntS("max", int32(cfg.GameConfig.A1.Max))
	xw.WriteDoubleS("odds", cfg.GameConfig.A1.Odds)

	xw.WriteSfsObjectPre("a2", uint16(3))
	xw.WriteIntS("min", int32(cfg.GameConfig.A2.Min))
	xw.WriteIntS("max", int32(cfg.GameConfig.A2.Max))
	xw.WriteDoubleS("odds", cfg.GameConfig.A2.Odds)

	xw.WriteSfsObjectPre("a3", uint16(3))
	xw.WriteIntS("min", int32(cfg.GameConfig.A3.Min))
	xw.WriteIntS("max", int32(cfg.GameConfig.A3.Max))
	xw.WriteDoubleS("odds", cfg.GameConfig.A3.Odds)

	xw.WriteSfsObjectPre("a4", uint16(3))
	xw.WriteIntS("min", int32(cfg.GameConfig.A4.Min))
	xw.WriteIntS("max", int32(cfg.GameConfig.A4.Max))
	xw.WriteDoubleS("odds", cfg.GameConfig.A4.Odds)

	xw.WriteSfsObjectPre("number", uint16(3))
	xw.WriteIntS("min", int32(cfg.GameConfig.N.Min))
	xw.WriteIntS("max", int32(cfg.GameConfig.N.Max))
	xw.WriteDoubleS("odds", cfg.GameConfig.N.Odds)

	xw.WriteSfsObjectPre("config", uint16(15))
	xw.WriteBoolS("isAutoBetFeatureEnabled", cfg.IsAutoBetFeatureEnabled)
	xw.WriteBoolS("isLoginTimer", cfg.IsLoginTimer)
	xw.WriteBoolS("isClockVisible", cfg.IsClockVisible)
	xw.WriteBoolS("isHideFreeBetsInUserMenu", cfg.IsHideFreeBetsInUserMenu)
	xw.WriteBoolS("isShowRtp", cfg.IsShowRtp)
	xw.WriteDoubleS("houseEdge", cfg.HouseEdge)
	xw.WriteBoolS("isGameNavigationEnabled", cfg.IsGameNavigationEnabled)
	xw.WriteIntArrayS("autoBetNumberOfRoundsList", cfg.AutoBetNumberOfRoundsList)
	xw.WriteStringS("activeGame", cfg.ActiveGame)
	xw.WriteBoolS("isGameRulesHaveMaxWin", cfg.IsGameRulesHaveMaxWin)

	//xw.WriteStringS("currency", cfg.Currency)
	//xw.WriteDoubleS("maxBet", utils.CalcIntDiv100(cfg.MaxBet))
	//xw.WriteDoubleS("minBet", utils.CalcIntDiv100(cfg.MinBet))
	//xw.WriteIntS("betPrecision", cfg.BetPrecision)
	//xw.WriteDoubleS("maxUserWin", utils.CalcIntDiv100(cfg.MaxUserWin))
	cfg.ConfigBin = append(cfg.ConfigBin, xw.Data()...)
}
